﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.Stereo3D.CCoStereo3DToggleCmd
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using EngineeringInternalExtension;
using Microsoft.Win32;
using System.Windows.Forms;
using Tecnomatix.Engineering;
using Tecnomatix.Engineering.Ui;


namespace DnProcessSimulateCommands.Stereo3D;

public class CCoStereo3DToggleCmd : TxToggleButtonCommand
{
  private const string OPTIONSSTEREO_PATH = "\\Options\\Stereo3D";
  private const string OPTIONSVIEWING_PATH = "\\Options\\Viewing";
  private const string STEREO3D_VALUE = "Stereo3DActive";
  private const string PARALLEL_MODE = "parallelMode";

  public virtual bool Push => TxApplicationEx.Stereo3DMode;

  public virtual string Category => StringTable.STEREO_3D_TOGGLE_CATEGORY;

  public virtual string Name => StringTable.STEREO_3D_TOGGLE_NAME;

  public virtual string Tooltip => StringTable.STEREO_3D_TOGGLE_TOOLTIP;

  public virtual string Description => StringTable.STEREO_3D_TOGGLE_DESCRIPTION;

  public virtual ITxImage Image => (ITxImage) TxImageManager.GetImageByKey("Stereo3DOnOff");

  public virtual ITxCommandEnabler CommandEnabler
  {
    get => (ITxCommandEnabler) new CCoStereo3DToggleEnabler();
  }

  public virtual void Execute(object cmdParams)
  {
    bool flag = !TxApplicationEx.Stereo3DMode;
    TxApplicationEx.Stereo3DMode = !TxApplicationEx.Stereo3DMode;
    TxApplication.Options.GraphicViewer.EnableToolbar = !TxApplicationEx.Stereo3DMode;
    TxApplication.Options.GraphicViewer.EnableNavigationCubeButtons = !TxApplicationEx.Stereo3DMode;
    if (flag && !TxApplicationEx.Stereo3DMode)
    {
      int num = (int) TxMessageBox.ShowModal(StringTable.STEREO_3D_TOGGLE_FAILED_MESSAGE, StringTable.STEREO_3D_TOGGLE_NAME, MessageBoxButtons.OK, MessageBoxIcon.Hand);
    }
    TxApplication.RefreshDisplay();
    this.SaveStateToRegistry();
  }

  private void SaveStateToRegistry()
  {
    Registry.CurrentUser.CreateSubKey(TxApplicationEx.ConfigurationPath + "\\Options\\Stereo3D").SetValue("Stereo3DActive", (object) (TxApplicationEx.Stereo3DMode ? 1 : 0));
    Registry.CurrentUser.CreateSubKey(TxApplicationEx.ConfigurationPath + "\\Options\\Viewing").SetValue("parallelMode", (object) 0);
  }
}
